package org.chenzhi.mvp.fragment;

import android.support.annotation.CallSuper;
import android.view.View;

import org.chenzhi.mvp.base.BasePresenter;
import org.chenzhi.mvp.base.BaseView;

/**
 * @author orange
 * @function
 */

public abstract class BaseMVPFragment<V extends BaseView, T extends BasePresenter<V>>
        extends BaseFragment implements View.OnClickListener {

    protected T mPresenter;

    @CallSuper
    protected void init(View view) {
        super.init(view);
        mvp();
    }

    private void mvp() {
        mPresenter = getPresenter();
        mPresenter.attach((V) this);
    }

    protected abstract T getPresenter();

    @Override
    public void onDestroyView() {
        super.onDestroyView();

        mPresenter.detach();
    }
}
